package command;

import model.EnhancedCostEvaluator;
import model.Solution;

public class RemoveProcessFromMachineCommand implements Command {

	EnhancedCostEvaluator costEvaluator;
	Solution new_solution;
	int p_id;
	int old_m_id = -1;

	public RemoveProcessFromMachineCommand(EnhancedCostEvaluator ce) {
		this.costEvaluator = ce;
		this.new_solution = costEvaluator.getNewSolution();
	}

	public void setP_id(int p_id) {
		this.p_id = p_id;
	}

	@Override
	public void execute() {
		old_m_id = new_solution.getMachineIdForProcessId(p_id);
		new_solution.removeProcess(p_id);
	}

	@Override
	public void undo() {
		new_solution.assignProcessToMachine(p_id, old_m_id);
		old_m_id = -1;
	}

	@Override
	public String toString() {
		return "RemoveProcessFromMachineCommand [old_m_id=" + old_m_id
				+ ", p_id=" + p_id + "]";
	}

}
